# _*_ coding: utf-8 _*_
# @Time     : 2022/7/22 17:23
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : sq_bianji.py
# @Software : PyCharm
from time import sleep
from appium import webdriver
from selenium.webdriver.common.by import By
desered_capabilities = {
    "platformName": "Android",  # 模拟器或真机的系统
    "deviceName": "127.0.0.1:62001",  # 系统版本号
    "platformVersion": "7.1.2",  # 设备名称，自定义设置
    "appPackage": "com.gfeng.daydaycook",  # app的包名
    "appActivity": "com.gfeng.daydaycook.activity.WelcomeActivity",  # app的activity
    "noReset": True,
    "unicodeKeyboard": True,
    "newCommandTimeout": 80,  # 等待时长
    "resetKeyboard": True  # 切换输入法
}

driver = webdriver.Remote("http://localhost:4723/wd/hub", desered_capabilities)
bianji = (By.ID, 'com.gfeng.daydaycook:id/tv_nickName')
touxiang = (By.ID, "com.gfeng.daydaycook:id/imgv_icon")
# zhaopian = (By.ID, "com.gfeng.daydaycook:id/iv_photo")
x = 500
y = 170
# wancheng = (By.ID, "com.gfeng.daydaycook:id/txv_done")
x1 = 140
y1 = 90
# baocun = (By.ID, "com.android.gallery3d:id/filtershow_done")
x2 = 100
y2 = 100
sex = (By.ID, "com.gfeng.daydaycook:id/rbt_boy")
yonghuming = (By.ID, "com.gfeng.daydaycook:id/edt_nickname")
jianjie = (By.ID, "com.gfeng.daydaycook:id/edt_intro")
driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()
baocun = (By.ID, "com.gfeng.daydaycook:id/rightButton")
sleep(2)
driver.find_element(*bianji).click()
sleep(3)
driver.find_element(*touxiang).click()
sleep(2)
driver.tap([(x, y)])
sleep(1)
driver.tap([(x1, y1)])
sleep(2)
driver.tap([(x2, y2)])
sleep(2)
driver.find_element(*yonghuming).click()
sleep(1)
driver.find_element(*yonghuming).send_keys("煮米大挑战")
sleep(1)
driver.find_element(*sex).click()
sleep(1)
driver.find_element(*jianjie).send_keys("这个人超级帅哦")
sleep(1)
driver.find_element(*baocun).click()
sleep(5)
driver.quit()